import { configureStore } from "@reduxjs/toolkit";
import undoable, { excludeAction, StateWithHistory } from "redux-undo";
import userReducer, { UserStateType } from "./userReducer";
import componentsReducer, { ComponentsStateType } from "./componentsReducer";
import pageInfoReducer, { PageInfoType } from "./pageInfoReducer";
export type StateType = {
  user: UserStateType;
//   components: ComponentsStateType;
  components: StateWithHistory<ComponentsStateType>; //undo
  pageInfo: PageInfoType;
};
export default configureStore({
  reducer: {
    //分模块
    user: userReducer, //用户信息
    //没有 undo redo 组件列表数据
    // components:componentsReducer,

    //有undo redo
    components: undoable(componentsReducer, {
      limit: 20, //限制undo 20步
      filter: excludeAction([
        "components/resetComponents",
        "components/changeSelectedId",
        "components/selectedPrevComponent",
        "components/selectedNextComponent"
      ]), //不进行撤销的功能
    }),

    //页面信息
    pageInfo: pageInfoReducer,
  },
});
